package com.haizhi.crm.api.controller.recommend;

import com.haizhi.crm.common.constant.CrmSchema;
import com.haizhi.crm.common.model.Response;
import com.haizhi.crm.recommend.constant.RecType;
import com.haizhi.crm.recommend.engine.RecEngine;
import com.haizhi.crm.recommend.model.RecQo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by yangyijun on 2018/7/4.
 */
@Api(description = "[客户-推荐]" )
@RestController
@RequestMapping("/companyRec" )
public class CompanyRecController {

    @Autowired
    private RecEngine recEngine;

    @ApiOperation(value = "获取热搜客户" )
    @GetMapping(path = "/hotSearch" )
    public Response hotSearch() {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.Company.SEARCH_HOT_SEARCH, null));
    }

    @ApiOperation(value = "获取最近浏览客户" )
    @GetMapping(path = "/recentView" )
    public Response recentView() {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.Company.SEARCH_RECENT_VIEW, null));
    }

    @ApiOperation(value = "区域新闻" )
    @GetMapping(path = "/areaNews" )
    public Response areaNews(@RequestParam String objectKey) {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.Company.DETAIL_AREA_NEWS, objectKey));
    }

    @ApiOperation(value = "行业舆情" )
    @GetMapping(path = "/industryInterest" )
    public Response industryInterest(@RequestParam String objectKey) {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.Company.DETAIL_INTERESTED, objectKey));
    }
}
